package com.transport.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.hibernate.classic.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.transport.utils.PageSet;

public class OrderDao extends HibernateDaoSupport{

	public Map queryOrderList(PageSet pageSet) {
		Map map = new HashMap();
		String sql = "select count(*) from Orderinfo";
		Long total = (Long) getHibernateTemplate().find(sql).get(0);
		Session session = getHibernateTemplate().getSessionFactory().openSession();
		Query q = session.createQuery("from Orderinfo");
		q.setFirstResult((pageSet.getPage() - 1) * pageSet.getRows());
		q.setMaxResults(pageSet.getRows());
		List list = q.list();
		map.put("total", total);
		map.put("rows", list);
		session.close();
		return map;
	}

}
